<template>
	<view>
		<view class="uni-list">
			<view class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in laugths" :key='index'>
				<view class="uni-list-cell-db">{{item.name}}</view>
				<switch @change="switchChange(item.value)" :checked="state == item.value" :disabled="state == item.value"/>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				laugths:[{
					name: '中文',
					value: 'zh-Hans'
				},
				{
					name: 'English',
					value: 'en'
				}],
				state: 'zh-Hans'
			}
		},
		onLoad() {
			this.state = uni.getStorageSync('UNI_LOCALE') || 'zh-Hans'
		},
		methods: {
			switchChange(e) {
				console.log(e,1111)
				this.state = e
				this.$i18n.locale = e
				uni.setLocale(e);
			},
			// onLocaleChange(e) {
			// 	if (this.isAndroid) {
			// 		uni.showModal({
			// 			content: this.$t('index.language-change-confirm'),
			// 			success: (res) => {
			// 				if (res.confirm) {
			// 					uni.setLocale(e.code);
			// 				}
			// 			}
			// 		})
			// 	} else {
			// 		uni.setLocale(e.code);
			// 		this.$i18n.locale = e.code;
			// 	}
			// }
		}
	}
</script>

<style scoped>
	.uni-list {
		background-color: #fff;
		position: relative;
		width: 100%;
		display: flex;
		flex-direction: column;
	}
	.uni-list-cell {
		position: relative;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}
	.uni-list-cell-pd {
		padding: 11px 15px;
	}
	.uni-list-cell::after {
		position: absolute;
		z-index: 3;
		right: 0;
		bottom: 0;
		left: 15px;
		height: 1px;
		content: "";
		-webkit-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;
	}
</style>
